package com.angc.poc.rules.drools.decisiontable.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.angc.drools.decisiontable.model.Product;
import com.angc.drools.decisiontable.model.User;
import static com.angc.drools.decisiontable.model.DecisionType.ACCEPTED;

@Component("financialServiceImpl")
public class FinancialServiceImpl implements FinancialService {

    private static final Logger LOGGER = LoggerFactory.getLogger(FinancialServiceImpl.class);

    public boolean processOrder(User user, Product product) {
        if(ACCEPTED.equals(user.getDecision())){
            LOGGER.debug("User has been approved - processing the order...");
            return true;
        }

        LOGGER.debug("Sorry, user has been rejected...");
        return false;
    }

}
